﻿Imports System.Data.SqlClient

Public Class clsMAQUINAS
    Public Function GUARDA_MAQUINA(ByVal CODIGO As String, ByVal NOMBRE As String, ByVal ESTATUS As Integer) As Integer
        Dim sql As String = "Insert Into MAQUINARIA VALUES(" & _
                           "@CODIGO," & _
                           "@NOMBRE," & _
                           "@ESTATUS)"
                           
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("CODIGO", CODIGO)
        Command.Parameters.AddWithValue("NOMBRE", NOMBRE)
        Command.Parameters.AddWithValue("ESTATUS", ESTATUS)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
            If RowsAffected > 0 Then
                cnConn.Close()
                GUARDA_MAQUINA = 1
            Else
                If cnConn.State = ConnectionState.Open Then
                    cnConn.Close()
                End If
                GUARDA_MAQUINA = 2
            End If
        Catch ex As Exception
            GUARDA_MAQUINA = -1
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
        End Try

    End Function
End Class
